package com.ada.dao;

import com.ada.io.Resources;
import com.ada.pojo.User;
import com.ada.sqlSession.SqlSession;
import com.ada.sqlSession.SqlSessionFactory;
import com.ada.sqlSession.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.util.List;

public class UserDaoImpl  {

//    @Override
//    public List<User> findAll() throws Exception {
//        InputStream inputStream = Resources.getResourceAsSteam("sqlMapConfig.xml");
//        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
//        SqlSession sqlSession = sqlSessionFactory.openSession();
//        User user = new User();
//        user.setId(1);
//        user.setUsername("张三");
////        User result = sqlSession.selectOne("user.selectOne", user);
////        System.out.println(result);
//        List<User> users = sqlSession.selectList("user.selectList");
//        for (User o : users) {
//            System.out.println(o);
//        }
//        return users;
//    }
//
//    @Override
//    public User findByCondition(User user) throws Exception {
//        InputStream inputStream = Resources.getResourceAsSteam("sqlMapConfig.xml");
//        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
//        SqlSession sqlSession = sqlSessionFactory.openSession();
//
//        User result = sqlSession.selectOne("user.selectOne", user);
//        System.out.println(result);
//
//        return result;
//    }
}
